<?php
include_once("../metier/question.dao.php");
include_once("../metier/question.class.php");
include_once("../metier/proposition.dao.php");
include_once("../metier/proposition.class.php");
include_once("../metier/reponse.dao.php");
include_once("../metier/reponse.class.php");
header("Content-Type: text/plain");

$db = new myPDO("127.0.0.1", "root", "", 0);
$questionDAO = new QuestionDAO();
$propositionDAO = new PropositionDAO();
$reponseDAO = new ReponseDAO();

$id = (isset($_GET["id"])) ? $_GET["id"] : NULL;
$question = new Question($id);
$tabIdProps = $propositionDAO->getPropositionsByQuestion($question, $db);

echo "<?xml version='1.0' encoding='UTF-8'?> \n\r" ;
echo "<listeDePropositions>"."\n\r" ;
foreach($tabIdProps as $ligne) {
	$reponse = new Reponse($ligne->getIdReponse());
	$reponse = $reponseDAO->findReponse($reponse, $db);
	echo "\t"."<reponse>"."\n\r" ;
	echo "\t\t"."<identifiant>"."\n\r\t\t\t".$reponse->getId()."\n\r\t\t"."</identifiant>"."\n\r";
	echo "\t\t"."<libelle>"."\n\r\t\t\t".$reponse->getLibelle()."\n\r\t\t"."</libelle>"."\n\r";
	echo "\t\t"."<description>"."\n\r\t\t\t".$reponse->getDescription()."\n\r\t\t"."</description>"."\n\r";
	echo "\t"."</reponse>"."\n\r";
}
echo "</listeDePropositions>"."\n\r" ;
?>